package cn.hhchat.wp.repository;

import cn.hhchat.wp.entity.JoinRelationEntity;
import cn.hhchat.wp.entity.GroupEntity;
import cn.hhchat.wp.entity.UserEntity;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

/**
 * Created this one by HMH on 2017/10/22.
 */
public interface JoinRelationRepository extends JpaRepository<JoinRelationEntity, Long> {

    int countByGroupAndIsActive(GroupEntity group, Boolean isActive);
    List<JoinRelationEntity> findByGroupAndIsActive(GroupEntity group, Boolean isActive);

    JoinRelationEntity findByGroupAndUser(GroupEntity group, UserEntity user);

    JoinRelationEntity findByGroupAndUserAndIsActive(GroupEntity group, UserEntity user, Boolean isActive);

    List<JoinRelationEntity> findByUserAndIsActiveAndGroup_IsFinished(UserEntity user, Boolean isActive, Boolean isFinished);

}
